package com.edushare.common.mailer;

import org.apache.cayenne.access.DataContext;

import com.edushare.common.constants.ApplicationConstants;
import com.edushare.common.dao.OutgoingEmailsDAO;
import com.edushare.common.orm.CayenneORMInterface;
import com.edushare.common.vo.OutgoingEmails;

public class SimpleMailer {
	
	public static void sendMail(String to, String content, String subject){
			CayenneORMInterface ormInterface = new CayenneORMInterface();
			ormInterface.setDataContext(DataContext.createDataContext());
			OutgoingEmails mail = new OutgoingEmails();
			mail.setContent(content);
			mail.setReceiverEmailId(to);
			mail.setStatus(OutgoingEmails.EMAIL_TO_BE_SENT);
			mail.setCopyType(1);
			mail.setSubject(subject);
			new OutgoingEmailsDAO(ormInterface).sendMail(mail);
	}
	
	public static void sendMail(String to, String content){
		sendMail(to, content, "Message from " + ApplicationConstants.APPLICATION_NAME);
	}
	

}
